<?php
	include_once("../includes/header.php");
	include_once("../includes/common.php");
	include_once("../includes/connect.php");
	include_once("../includes/functions.php");

	if (isset($_GET["i"]))
	{
		$qcategory_info_sql = "SELECT * from qcategory WHERE id = '".$_GET["i"]."'";
		$qcategory_info = $conn1->Execute($qcategory_info_sql);

		if ($qcategory_info->RecordCount() > 0)
		{

			if ($_SERVER['REQUEST_METHOD'] == "POST")
			{
				if ($_POST["submit"] != "No")
				{
					$mode = "edit";
					include_once("../includes/validateqcategory.php");
				}
			}
			
			if (sizeof($errors) > 0 || ($_SERVER['REQUEST_METHOD'] == "POST" && $_POST["submit"] == "No") || $_SERVER['REQUEST_METHOD'] != "POST")
			{
	?>
	<h3>Update Question Group - <i><?php echo $qcategory_info->fields["name"];?></i></h3>
	<form action="<?php echo $_SERVER['../qcategory/PHP_SELF']."?".$_SERVER['QUERY_STRING']; ?>" method="post" >
		<ol>
		  <li>
			<label for="name">Category Name *</label>
			<input name="qcategoryname" class="text" value="<?php echo (isset($_POST["qcategoryname"])) ? $_POST["qcategoryname"] : $qcategory_info->fields["name"] ?>" />
		  </li>
		  <li>
			<label>&nbsp;</label>
			<input type="submit" name="submit" value="Submit" onClick="" />
		  </li>
		</ol>
	</form>	 

<?php 
			}
		}
		else
			header("Location: viewqcategories.php"); // redirect if bad id
	}
	else
		header("Location: viewqcategories.php"); // redirect if no id supplied
	include_once("../includes/sidebar.php");
	include_once("../includes/footer.php");
?>
